package com.itboye.jinpuyiyuan.activity.me;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.base.BaseActivity;
import com.itboye.jinpuyiyuan.presenter.BranchAddressPresenter;
import com.itboye.jinpuyiyuan.utils.sputil.Const;
import com.itboye.jinpuyiyuan.utils.sputil.SPUtils;
import com.itboye.jinpuyiyuan.utils.volley.ResultEntity;
import com.itboye.jinpuyiyuan.widget.loadingutil.MAlert;

import java.util.Observable;
import java.util.Observer;

/**
 * 意见反馈
 */
public class FeedBackActivity extends BaseActivity implements Observer {
    //title
    private ImageView leftImg,rightImg;
    private TextView leftTv,tvTitle;
    private RelativeLayout rlLeft,toobar;

    private TextView real_ok;
    private EditText fankui_et;
    private BranchAddressPresenter presenter;

    private String uid,realname,tel,email,img_id,extra;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feed_back);
        rightImg.setVisibility(View.GONE);
        leftTv.setVisibility(View.GONE);
        tvTitle.setText("意见反馈");
        presenter=new BranchAddressPresenter(this);
//        uid= (String) SPUtils.get(getApplication(),null, Const.UID,"");
//        realname= (String) SPUtils.get(getApplication(),null,Const.RealName,"");
//        tel= (String) SPUtils.get(getApplication(),null,Const.MOBILE,"");
//        email=SPUtils.get(getApplication(),null,Const.)
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()){
            case R.id.rlLeft:
            case R.id.leftImg:
              this.finish();
                break;
            case R.id.real_ok:
              if (fankui_et.getText().toString()==null){
                  MAlert.alert("请输入您的意见");
              }
                presenter.suggestContent("","",fankui_et.getText().toString(),"","","","");
                break;
        }
    }

    @Override
    public void update(Observable o, Object arg) {
        ResultEntity resultEntity = handlerError(arg);
        if (resultEntity!=null){

            if (resultEntity.getEventType()==BranchAddressPresenter.By_Suggest_add_success){
                MAlert.alert(resultEntity.getMsg()+resultEntity.getData());
                FeedBackActivity.this.finish();
            }else if (resultEntity.getEventType()==BranchAddressPresenter.By_Suggest_add_fail){

//                MAlert.alert(resultEntity.getMsg()+"提交信息有误请检查后再提交");
            }
        }
    }
}
